import { createApi, useApi } from './api';

const apiWeather = createApi({
  name: 'weather',
  baseURL: 'https://api.open-meteo.com/v1',
  parser: data => {
    if (data.error) {
      throw new Error(data.reason);
    }
    return data;
  },
});

const useWeatherApi = () => useApi('weather');

export { apiWeather, useWeatherApi };
